<?php


namespace app\platform\system\controller;

use app\common\controller\BaseController;
class TestController extends BaseController
{
    protected array $noNeedLogin = ['*'];

    public function index()
    {
        $path = "D:\project\webman-project\bs-saas-admin\bs-admin\app\merchant\controller";
        $namespace = "app\\merchant\\controller";

        $files = scandir($path);
        foreach ($files as $file) {
            if ($file == '.' || $file == ".." || $file == "BaseController.php") {
                continue;
            }
            $cname = str_replace(".php", '', $file);
            $cname1 = self::classToName(str_replace("Controller", '', $cname));

            $class = $namespace . '\\' . $cname;
            $xx = new \ReflectionClass($class);
            foreach ($xx->getMethods() as $method) {
                if ($method->getName() == "getModel"
                    || $method->getName() == "success"
                    || $method->getName() == "error") {
                    continue;
                }
                $auth = $cname1 . ':' . $method->getName();
                dump($auth);
            }

        }
    }

    public static function classToName($class)
    {
        $class = lcfirst($class);
        return preg_replace_callback(['/([A-Z])/'], function ($matches) {
            return '_' . strtolower($matches[1]);
        }, $class);
    }
}